Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eslint config #228

Merged
merged 4 commits into from
Oct 22, 2019
Merged

Eslint config #228

merged 4 commits into from
Oct 22, 2019

Conversation

hasparus
Copy link
Contributor

Hi there 👋

I'm fiddling around #172 and I've noticed few problems with ESLint config in the repo (it doesn't parse TS files, eslint script in package.json doesn't run etc.)

I've extended few defaults and compatibility rule configs (which disable rules redundant in TS) and made them a little bit less strict.

yarn eslint now prints

✖ 104 problems (15 errors, 89 warnings)
  11 errors and 37 warnings potentially fixable with the `--fix` option.

which are mostly no-unused-vars and react-hooks/exhaustive-deps

I'm kinda afraid of running --fix.

I've configured @typescript-eslint, extended few defaults and
compatibility rule configs which disable rules redundant in TS.

```json
{
  "overrides": [
    {
      "files": ["*.ts", "*.tsx"],
      "parser": "@typescript-eslint/parser",
      "plugins": ["@typescript-eslint"],
      "parserOptions": {
        "ecmaFeatures": { "jsx": true },
        "ecmaVersion": 2018,
        "project": "./tsconfig.json",
        "sourceType": "module"
      },
      "extends": [
        "plugin:@typescript-eslint/recommended",
        "plugin:@typescript-eslint/eslint-recommended",
        "prettier/@typescript-eslint"
      ],
      "rules": {
        "import/no-unresolved": "off",
        "no-useless-constructor": "off",
        "@typescript-eslint/no-useless-constructor": "error",
        "@typescript-eslint/no-namespace": "off",
        "@typescript-eslint/no-explicit-any": "off",
        "@typescript-eslint/no-use-before-define": "off",
        "@typescript-eslint/no-parameter-properties": "off",
        "@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }],
        "@typescript-eslint/explicit-function-return-type": "off",
      }
    }
  ]
}
```

I've added two entries below to decrease the number of ESLint violations
to 15. They are not "errors" and won't lead to a bug so there's probably
no use to bother with them ATM.

```
  "@typescript-eslint/no-inferrable-types": "warn",
  "@typescript-eslint/no-empty-function": "off"
```
@drcmda
Copy link
Member

drcmda commented Oct 20, 2019

what happens when you do --fix? does it ... fix it? 😇

@hasparus
Copy link
Contributor Author

what happens when you do --fix? does it ... fix it? 😇

Some of the rules have an autofix implemented and though I believe only autofixes that don't change behavior are included, but I'm not really comfortable with the codebase yet and I didn't PR a feature nor a big bugfix, so I'm not sure if it would be polite to run autofixes on your code and tell you what keyword to use when declaring variables.

I don't really care much for ESLint's consistency rules personally, prefering bug or mistake detection rules, but I wanted error squiggles to go away 🙈 and there was a eslint:recommended extended already.

@hasparus
Copy link
Contributor Author

I described some of the changes in the commit message a4e7002.

@drcmda drcmda merged commit 037f616 into pmndrs:master Oct 22, 2019
@hasparus hasparus deleted the eslint-config branch October 23, 2019 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants